package com.yocard.yxyd.ui.activity;

import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.yocard.yxyd.utils.util.ActivityUtils;
import com.gyf.barlibrary.ImmersionBar;
import com.ogaclejapan.smarttablayout.SmartTabLayout;
import com.yocard.yxyd.R;
import com.yocard.yxyd.adapter.FragmentAdapter;
import com.yocard.yxyd.ui.activity.base.SimpleActivity;
import com.yocard.yxyd.ui.fragment.AllTransactionFragment;

import java.util.Arrays;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created on 2019/4/10.
 * 交易记录 19/05/04
 */
public class TransactionActivity extends SimpleActivity {

    @BindView(R.id.tv_right)
    TextView tvRight;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tab_layout)
    SmartTabLayout smartTabLayout;
    @BindView(R.id.view_pager)
    ViewPager viewPager;

    private String[] mVals = new String[]{"全部", "收入", "支出 "};
    private Class[] mClszz = new Class[]{AllTransactionFragment.class, AllTransactionFragment.class, AllTransactionFragment.class};

    @Override
    protected int getLayout() {
        return R.layout.act_transaction;
    }

    @Override
    protected void initEventAndData() {
        initTitle();
        initViewpager();
    }

    private void initViewpager() {
        FragmentAdapter mAdapter = new FragmentAdapter(getSupportFragmentManager(), Arrays.asList(mVals), Arrays.asList(mClszz));
        viewPager.setAdapter(mAdapter);
        smartTabLayout.setViewPager(viewPager);
        viewPager.setOffscreenPageLimit(3);
    }

    private void initTitle() {
        ImmersionBar.with(this).statusBarColor(R.color.white)
                .statusBarDarkFont(true).navigationBarColor(R.color.white).init();
        tvTitle.setText("交易记录");
    }

    @OnClick({R.id.iv_back})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                ActivityUtils.finishActivity(this);
                break;
        }
    }
}
